<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>奖惩机制-分数计算</title>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">		
		<link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
	</head>
	<body>
		<div class="container mt-3">

			<nav aria-label="breadcrumb">
			  <ol class="breadcrumb">
				<li class="breadcrumb-item active"><a href="/index.html">Pure search</a></li>
				<li class="breadcrumb-item"><a href="/pages/AssessmentList.html">Assessment List</a></li>
			  </ol>
			</nav>
			
			<div>
				<hr>
				最后更新时间：2020-08-07 19:35:06
				<hr>
			</div>
			
			<div>
				<!-- 基础模块 -->
				<div>
					<h4>本模块为基础模块（35%）</h4>
					<div>
						<label>早起（10%）</label>
						<input id="getUp"/> %
					</div>
					
					<div>
						<label >早睡（15%）</label>
						<input id="sleep"/> %
					</div>
					
					<div>
						<label >锻炼（10%）</label>
						<input id="exercise"/> %
					</div>
				</div>
				
				<hr />
				
				<!-- 学习模块 -->
				<div>
					<h4>本模块为学习模块（65%）</h4>
					<div>
						<label>数学（30%）</label>
						<br />
						<input id="maths" placeholder="花费时间(到分)"/>
					</div>
					
					<div>
						<label>英语（10%）</label>
						<ul >
							<label>单词（5%）+阅读（3%）+翻译（2%）</label>
							<br />
							<input id="en_combination" /> 
						</ul>
					</div>
					
					<div>
						<label>专业课（20%）</label>
				
						<ul >
							<label>数据结构 / 操作系统 / 计网（20%）</label>
							<br />
							<input id="profession_combination"/> 
						</ul>
					</div>
					
					<div>
						<label>政治（5%）</label>
						<ul >
							<label>精讲精练知识点（5%）</label>
							<br />
							<input id="politic_combination"/> 
						</ul>
					</div>

				</div>
				
				<hr />
				
				<!-- 额外奖励或惩罚 -->
				<div>
					<h4>额外奖励或惩罚（无上限）</h4>
					<div>
						<h5>奖励</h5>
						<div>
							<label>辛苦补贴（10%）
								<input type="radio" name="hard_working" value="10"/>
							</label>
							<button class="btn" onclick="cancelHard()">取消辛苦补贴</button>
						</div>
						<div>
							<label>不浪费时间（10%）</label>
							<button class="btn" onclick="cancelNotWaste()">取消不浪费时间奖励</button>
							<br />
							<label>
								<input id="notWasteTime5" name="notWasteTime" type="radio" value="5"/>（5%）
							</label>
							<br />
							<label>
								<input id="notWasteTime10" name="notWasteTime" type="radio" value="10"/> （10%）
							</label>
						</div>
						<div>
							特殊奖励
							<input id="specialReward" />
						</div>
						
					</div>
					
					<div>
						<h5>惩罚</h5>
						<div>
							<label>浪费时间（-10%）</label>
							<input id="wasteTime" /> %
						</div>
					</div>
				</div>
				
				<hr />
				
				<!-- 计算与结果 -->
				<div>
					<button id="calc" onclick="calculate()" class="btn btn-danger">计算</button>
					<hr />
					<div>结果：</div>
					<div id="score">0</div>
					<div id="comment">无</div>
				</div>
			</div>
		</div>
		
		<script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
		<script type="text/javascript" src="https://unpkg.com/vue/dist/vue.js"></script>
		<script type="text/javascript">
			function cancelHard() {
				$("input[name='hard_working']").prop("checked",0);
			}
			
			function cancelNotWaste() {
				$("input[name='notWasteTime']").prop("checked",0);
			}
			
			
			
			function calculate() {
				var ans = 0;

				// 基本模块
				let getUp = parseInt(document.getElementById("getUp").value);
				getUp = getUp||0; 
				
				let sleep = parseInt(document.getElementById("sleep").value);
				sleep = sleep||0;
				
				let exercise = parseInt(document.getElementById("exercise").value);
				exercise = exercise||0;
				
				let basic = getUp + sleep + exercise
				
				console.log("basic", basic);
				
				// 学习模块
				// 数学
				let mathsValue = document.getElementById("maths").value;
				mathsTime = mathsValue.split(":");
				mathsHours = parseInt(mathsTime[0]);
				mathsMinutes = parseInt(mathsTime[1]);
				mathsPercent = ((mathsHours*60 + mathsMinutes) / 360) * 30;
				
				console.log("mathsPercent", mathsPercent)
				
				let maths = mathsPercent||0;
				console.log("maths", maths)
				
				// 英语
				let en_combination = parseInt(document.getElementById("en_combination").value);
				en_combination = en_combination||0;

				let en = en_combination;
				console.log("en", en);
				
				// 专业课
				let professionValue = document.getElementById("profession_combination").value;
				professionTime = professionValue.split(":");
				professionHours = parseInt(professionTime[0]);
				professionMinutes = parseInt(professionTime[1]);
				professionPercent = ((professionHours*60 + professionMinutes) / 180) * 20;

				let profession = professionPercent;
				console.log("profession", profession);

				// 政治
				let politic_combination = parseInt(document.getElementById("politic_combination").value)
				politic_combination = politic_combination||0;

				let politic = politic_combination;
				console.log("politic", politic);
				
				// 额外奖励
				let hard_working = parseInt($("input[name='hard_working']:checked").val())
				hard_working = hard_working||0;
				
				let notWasteTime =  parseInt($("input[name='notWasteTime']:checked").val())
				notWasteTime = notWasteTime||0
				
				let specialReward = parseInt(document.getElementById("specialReward").value)
				specialReward = specialReward||0
				
				let extraReward = hard_working +notWasteTime + specialReward;
				console.log("extra reward", extraReward);
				
				// 额外惩罚
				let wasteTime = parseInt(document.getElementById("wasteTime").value)
				wasteTime = wasteTime||0;
				
				let extraPunish = -wasteTime;
				console.log("extra punishment", extraPunish);
		
				// 最终结果
				console.log(ans);
				ans = basic + maths + en + profession + politic + extraReward + extraPunish;
				
				let comment = "";
				
				// 判断结果
				if (ans >= 90) {
					comment = "👆"
				} else if (ans >= 80) {
					comment = "👆，平"
				} else if (ans >= 70) {
					comment = "平"
				} else if (ans >= 60) {
					comment = "👇，平"
				} else {
					comment = "👇"
				}
				
				document.getElementById('score').innerHTML = ans;
				document.getElementById('comment').innerHTML = comment
			}
			
			
		</script>
		
	</body>
</html>
